import os
import random
import string

# 目标输出目录
out_dir = r"C:\Users\ASUS\Desktop\2025-BBUCPC\2025校赛出题\B题\B_inputs"
os.makedirs(out_dir, exist_ok=True)

# 定义每个类别对应的样例数量、n的范围和字符串长度的范围
categories = [
    (10, (5, 10), (3, 15)),    # 50% 的样例，共 10 个
    (4, (10, 20), (7, 20)),    # 20% 的样例，共 4 个
    (2, (20, 40), (20, 40)),   # 10% 的样例，共 2 个
    (2, (40, 60), (20, 60)),   # 10% 的样例，共 2 个
    (2, (60, 100), (1, 100)),  # 10% 的样例，共 2 个
]

test_cases = []

# 根据各类别生成样例
for count, n_range, len_range in categories:
    for _ in range(count):
        n = random.randint(*n_range)  # 随机确定当前样例的字符串数量
        strings = []
        for _ in range(n):
            # 随机确定字符串长度，并生成由小写字母组成的字符串
            length = random.randint(*len_range)
            s = ''.join(random.choices(string.ascii_lowercase, k=length))
            strings.append(s)
        test_cases.append((n, strings))

# 为了使生成的样例顺序更加随机，可以将所有样例打乱顺序
random.shuffle(test_cases)

# 将每个测试点写入对应的 .in 文件中
for idx, (n, strings) in enumerate(test_cases, 1):
    filename = os.path.join(out_dir, f"{idx}.in")
    with open(filename, "w") as f:
        f.write(f"{n}\n")
        for s in strings:
            f.write(s + "\n")

print("生成20个测试点完成！")
